package com.dili.dd.gpi.service;

import com.dili.dd.gpi.domain.GpiSnapshot;
import com.dili.dd.gpi.enums.ApplyType;
import com.dili.dd.gpi.enums.EventType;
import com.dili.dd.gpi.enums.GPIType;
import com.dili.dd.gpi.exception.BusinessException;
import com.dili.dd.gpi.util.Pagination;
import com.dili.dd.gpi.util.spring.DataSourceLookupKey;
import com.dili.dd.gpi.util.spring.RequireDataSource;

import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;

/**
 * Created by zhaoYuan on 2015/3/24.
 */
public interface GpiSnapshotService {

    EventType DEFAULT_EVENT = EventType.CLICK;

    /**
     * 申请位置标注
     * @param titles
     * @param type
     * @param descriptions
     * @param gpiSnapshots 用来接收申请到的gpi值
     * @param applyType 用来接收申请到的gpi值
     * @return 表示申请成功还是失败。
     */
    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    boolean apply(Integer parentId, LinkedHashSet<String> titles, GPIType type,String prefix,String suffix,List<String> descriptions,
                   List<GpiSnapshot> gpiSnapshots,List<GpiSnapshot> newGpis,ApplyType applyType) throws BusinessException;

    /**
     * 查询列表
     * @param params
     * @param pagination
     * @return
     */
    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    List<GpiSnapshot> find( Map<String,Object> params,Pagination pagination);


    /**
     * 检查title指定的gpi是否存在，如果存在，返回该gpi信息
     * @param titles
     * @param type
     * @return 如果title存在，返回该title对应的GpiSnapshot。否则返回空
     */
    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    List<GpiSnapshot> isExist( List<String> titles, GPIType type) ;

    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    GpiSnapshot get(Integer id);

    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    List<GpiSnapshot> subList(int id);

    /**
     * 查找所有的系统
     * @return
     */
    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    List<GpiSnapshot> findAllSystem();

    /**
     * 查找指定页面下的全部gpi
     * @param pageGpi
     * @return
     */
    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    List<GpiSnapshot> findByPage(String pageGpi);

    /**
     * 根据gpi和层级获取
     * @param gpi
     * @param gpiType
     * @return
     */
    @RequireDataSource(key = DataSourceLookupKey.GPI_DATASOURCE)
    GpiSnapshot getByGpi(String gpi,GPIType gpiType);


}
